function getMyWorks(accessToken, pageId, limit, status) {
  const endpoint = APP_CONFIG.endPoint;

  return Hfetch.get(`${endpoint}/asset-store/me/assets`, {
    pageId, limit, status,
  }, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function getMyPublishedWorks(accessToken, pageId, limit) {
  return getMyWorks(accessToken, pageId, limit, 'PUBLIC');
}

export function getMyUploadsWorks(accessToken, pageId, limit) {
  return getMyWorks(accessToken, pageId, limit, 'PRIVATE');
}

export function getMyLikedWorks(accessToken, pageId, limit) {
  const endpoint = APP_CONFIG.endPoint;

  return Hfetch.get(`${endpoint}/asset-store/me/likes`, {
    pageId, limit,
  }, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function updateMyWork(accessToken, assetId, name, title, categoryId, description) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.put(`${endpoint}/asset-store/me/assets`, {
    assetId, name, title, categoryId, description,
  }, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function changeMyWork(accessToken, assetId, status) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.patch(`${endpoint}/asset-store/me/assets`, {
    assetId, status,
  }, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function deleteMyWork(accessToken, assetId) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.del(`${endpoint}/asset-store/me/assets/${assetId}`, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function getMyWorkDetail(accessToken, assetId) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.get(`${endpoint}/asset-store/me/assets/${assetId}`, {}, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function likeThisWork(accessToken, assetId) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.post(`${endpoint}/asset-store/me/likes`, { assetId }, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function unlikeThisWork(accessToken, assetId) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.del(`${endpoint}/asset-store/me/likes?assetId=${assetId}`, {
    headers: {
      Authorization: accessToken,
    },
  });
}

export function getMyLikeStatus(accessToken, assetId) {
  const endpoint = APP_CONFIG.endPoint;
  return Hfetch.get(`${endpoint}/asset-store/me/likes/${assetId}`, {}, {
    headers: {
      Authorization: accessToken,
    },
  }).then(data => ({
    liked: data.isLiked,
  }));
}
